import { Directive, ElementRef , Input , OnInit} from '@angular/core';

@Directive({
  selector: '[appMargin]'
})
export class MarginDirective implements OnInit {
  @Input('appMargin') margin: string;
  @Input('top') top: string;
  @Input('bottom') bottom: string;
  constructor(private el: ElementRef ) {

  }

  ngOnInit() {
      this.margin = this.margin || '0';
      this.top = this.top || '0';
      this.bottom = this.bottom || '0';
      this.el.nativeElement.style.marginLeft = this.margin + 'px';
      this.el.nativeElement.style.marginRight = this.margin + 'px';
      this.el.nativeElement.style.marginTop = this.top + 'px';
      this.el.nativeElement.style.marginBottom = this.bottom + 'px';
  }


}
